<template>
  <div>
    <el-container>
      <el-header>&nbsp;人力资源管理系统</el-header>
      <el-container class="container">
        <el-aside width="300px">
          <Menu>
          </Menu>
        </el-aside>
        <el-container>
          <el-main>
            <el-row>
              <el-col :span="22">
                <div class="grid-content bg-purple-dark">
                  奖惩管理
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content">
                  <el-button type="success" round @click="submit(item)">提交</el-button>
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    档案编号
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <span>
                    姓名
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple">
                  <span>
                    出勤情况
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple-light">
                 <span>
                    工作表现
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple">
                  <span>
                    绩效及工作态度
                  </span>
                </div>
              </el-col>

            </el-row>
            <el-row
                v-for="(item, index) in rewardsAndPunishments" :key="index">
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  {{ item.fileId }}
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  {{ item.name }}
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple">
                  <el-select v-model="item.workattendance" placeholder="请选择" style="width: 100%">
                    <el-option
                        v-for="option in rp.workattendance"
                        :key="option.value"
                        :label="option.label"
                        :value="option.value"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple-light">
                  <el-select v-model="item.workperformance" placeholder="请选择" style="width: 100%">
                    <el-option
                        v-for="option in rp.workperformance"
                        :key="option.value"
                        :label="option.label"
                        :value="option.value"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple">
                  <el-select v-model="item.workattitude" placeholder="请选择" style="width: 100%">
                    <el-option
                        v-for="option in rp.workattitude"
                        :key="option.value"
                        :label="option.label"
                        :value="option.value"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>

            </el-row>
            <el-row></el-row>
            <el-row>
              <el-col :span="24">
                <div class="grid-content bg-purple">
                  奖惩明细表
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    考勤情况
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <span>
                    全勤
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple1">
                  <span>
                    有缺勤情况
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple-light">
                 <span>
                    缺勤较严重
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple1">
                  <span>
                    缺勤严重
                  </span>
                </div>
              </el-col>

            </el-row>

            <el-row>
              <el-col :span="4">
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <span>
                    奖金400.00元
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple1">
                  <span>
                    无奖惩
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple-light">
                 <span>
                    罚款100.00
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple1">
                  <span>
                    罚款300.00
                  </span>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    工作表现
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <span>
                    优秀
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple1">
                  <span>
                    良好
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                 <span>
                    一般
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple1">
                  <span>
                    较差
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                 <span>
                    很差
                  </span>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="4">
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <span>
                    奖金1500.00元
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple1">
                  <span>
                     奖金500.00元
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                 <span>
                    无奖惩
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple1">
                  <span>
                    罚款300.00
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                 <span>
                   罚款500.00
                  </span>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    绩效及工作态度
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <span>
                    优秀
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple1">
                  <span>
                    良好
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                 <span>
                    一般
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple1">
                  <span>
                    较差
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                 <span>
                    很差
                  </span>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="4">
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <span>
                    奖金1500.00元
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple1">
                  <span>
                     奖金500.00元
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                 <span>
                    无奖惩
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple1">
                  <span>
                    罚款300.00
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                 <span>
                   罚款500.00
                  </span>
                </div>
              </el-col>
            </el-row>


          </el-main>
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { defineComponent, ref } from 'vue'
import {
  Location,
  Document,
  Menu as IconMenu,
  Setting,
} from '@element-plus/icons-vue'
import Menu from "@/components/Menu";

export default defineComponent({
  name: "SalaryDistributionRegistrationDetail",
  components: {
    Menu,
    Location,
    Document,
    Setting,
    IconMenu,
  },
  data() {
    return {
      rewardsAndPunishments: [],
      rp: {
        workattendance: [
          { value: "全勤", label: "全勤" },
          { value: "有缺勤情况", label: "有缺勤情况" },
          { value: "缺勤较严重", label: "缺勤较严重" },
          { value: "缺勤严重", label: "缺勤严重" },
        ],
        workperformance: [
          { value: "优秀", label: "优秀" },
          { value: "良好", label: "良好" },
          { value: "一般", label: "一般" },
          { value: "较差", label: "较差" },
          { value: "很差", label: "很差" },
        ],
        workattitude: [
          { value: "优秀", label: "优秀" },
          { value: "良好", label: "良好" },
          { value: "一般", label: "一般" },
          { value: "较差", label: "较差" },
          { value: "很差", label: "很差" },
        ]
      }
    }
  },
  setup() {
    const activeNames = ref(['1'])
    const handleChange = (val) => {
      console.log(val)
    }
    return {
      activeNames,
      handleChange,
    }
  },
  methods: {
    createRewardsAndPunishment() {
      return {
        fileId: '',
        name: '',
        workattendance: '',
        workperformance: '',
        workattitude: '',
      }
    },
    submit(item) {
      const _this = this;
      const dataToSend = this.rewardsAndPunishments.map(item => ({
        fileId: item.fileId,
        name: item.name,
        workattendance: item.workattendance,
        workperformance: item.workperformance,
        workattitude: item.workattitude,
      }));

      _this.axios.post('/RewardsAndPunishment', dataToSend)
          .then(response => {
            alert("提交成功")
            _this.$router.push("/SalaryDistributionRegistration")
            console.log('Data submitted successfully:', response);
            // Handle success, e.g., show a message to the user
          })
          .catch(error => {
            console.error('Error submitting data:', error);
            // Handle error, e.g., show an error message to the user
          });
    }
  },
  created() {
    const _this = this;
    _this.axios.get("/GetSalaryDistributionListDetail").then(res => {
      res.data.data.forEach(item => {
        const rewardAndPunishment = _this.createRewardsAndPunishment();
        rewardAndPunishment.fileId = item.fileId;
        rewardAndPunishment.name = item.name;
        _this.rewardsAndPunishments.push(rewardAndPunishment);
      });
    });
  },
})
</script>

<style scoped>
.el-header{
  background-color: #409EFF;
  color: #e9eef3;
  text-align: left;
  line-height: 60px;
  font-size: 30px;
}
.el-aside {
  background-color: #d3dce6;
  color: var(--el-text-color-primary);
  text-align: center;
  /*line-height: 860px;*/
}

.el-main {
  background-color: #e9eef3;
  color: var(--el-text-color-primary);
  text-align: center;
  line-height: 30px;
}

body > .el-container {
  margin-bottom: 400px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-row {
  margin-bottom: 20px;
}

.el-row :last-child {
  margin-bottom: 0;
}

.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.bg-purple1 {
  background: #ecf0f8;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

.high-row{
  min-height: 200px;
}

.container{
  min-height: 860px;
}

.line {
  width: 70%;
}

.line div {
  width: 100%;
  height: 0;
  border-top: 1px solid var(--el-border-color-base);
}

</style>
